#include "Artman.h"

Art::Art(std::string fname)
{
	m_filename=fname;
	m_image.loadFromFile("art/"+fname);
//	m_image.createMaskFromColor(sf::Color(255, 0, 255));
	m_texture.loadFromImage(m_image);
}

Artman::Artman()
{

}

Artman::~Artman()
{
	if (m_art.size()>0)
	{
		for (int i=0;i<m_art.size();i++)
		{
			delete m_art[i];
		}
	}
}

sf::Texture *Artman::getTexture(std::string filename)
{
	if (m_art.size()==0)
	{
		m_art.push_back(new Art(filename));
		return &m_art[0]->m_texture;
	}
	else
	{
		for (int i=0;i<m_art.size();i++)
		{
			if (m_art[i]->m_filename==filename)
			{
				return &m_art[i]->m_texture;
			}
		}
		m_art.push_back(new Art(filename));
		return &m_art[m_art.size()-1]->m_texture;
	}
}